﻿using System;
using System.Web.UI.WebControls;
using ElectronStoreDAL;

namespace ElectronStore
{
	public partial class Product : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			int idProduct;
			if(int.TryParse(Request.Params["id"], out idProduct))
			{
				ElectronStoreSource storeSource=new ElectronStoreSource();
				ElectronStoreDAL.Product product = storeSource.GetProductById(idProduct);
                Label lbl=new Label();

                if (product == null)
                {
                    lbl.Text = GeneralResource.productIsNot;
                    panelHead.Controls.Add(lbl);
                    return;
                }
				
				lbl.Text = product.Name + " из категорий:  ";
				foreach (Category cat in product.Categories)
				{
					lbl.Text += cat.Name + "; ";
				}

				panelHead.Controls.Add(lbl);
				largePhoto.HRef = string.Format(GeneralResource.urlLargeImage, idProduct.ToString());
                smallPhoto.Src = string.Format(GeneralResource.urlSmallImage, idProduct.ToString());
				largePhoto.Title = product.Name;
				divParam.InnerText = product.Info;
			}
		}

	}   //public partial class Product : System.Web.UI.Page

}   //namespace ElectronStore





